package com.sls.game.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.sls.game.dao.GoodsOrderLogDAO;
import com.sls.game.page.Pagination;
import com.sls.game.pojo.GoodsOrderLog;
import com.sls.game.querybean.GoodsOrderLogQuery;

@Repository("goodsOrderLogDAO")
public class GoodsOrderLogDAOImpl extends SuperDAO<GoodsOrderLog> implements
		GoodsOrderLogDAO {

	@Override
	public void insert(GoodsOrderLog goodsOrderLog) {
		this.getSqlSession().insert("mybatis.xml.GoodsOrderLogMapper.insert",
				goodsOrderLog);
	}

	@Override
	public GoodsOrderLog queryById(String id) {
		GoodsOrderLog orderLog = this.getSqlSession().selectOne(
				"mybatis.xml.GoodsOrderLogMapper.queryLogById", id);
		return orderLog;
	}

	@Override
	public Pagination<GoodsOrderLog> queryOrderLog(
			GoodsOrderLogQuery orderLogQuery) {
		Integer rows = this.queryRowCount(orderLogQuery);
		orderLogQuery.calculate();
		List<GoodsOrderLog> list = this.queryOrderInfoList(orderLogQuery);
		Pagination<GoodsOrderLog> page = super.queryPagination(rows, list,
				orderLogQuery);
		return page;
	}

	/**
	 * 查询记录总数
	 * 
	 * @param pageInruire
	 * @return
	 */
	private Integer queryRowCount(GoodsOrderLogQuery orderLogQuery) {
		Integer rowCount = this.getSqlSession().selectOne(
				"mybatis.xml.GoodsOrderLogMapper.queryOrderLogRow",
				orderLogQuery);
		return rowCount;
	}

	/**
	 * 记录结果集list
	 * 
	 * @param goodsManageInfo
	 * @return
	 */
	private List<GoodsOrderLog> queryOrderInfoList(
			GoodsOrderLogQuery orderLogQuery) {
		List<GoodsOrderLog> list = this.getSqlSession().selectList(
				"mybatis.xml.GoodsOrderLogMapper.queryOrderLogList",
				orderLogQuery);
		return list;
	}

}
